<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="{{ asset('/crm/css/common.css')  }}">
    <link rel="stylesheet" href="{{ asset('/crm/css/login.css')  }}">
    <script type="text/javascript" src="{{ asset('/crm/js/jquery.min.js') }}"></script>
    <script type="text/javascript" src="{{ asset('/crm/js/layer.js') }}"></script>
    <title>登录</title>
</head>
<body>
<div class='bg'>
    <div class='login-box clearfix'>
        <div class='login-left p-l'>
            <div class='login-img-box'>
                <img src="/crm/img/dl_wenzi.png" alt="">
            </div>
        </div>
        <div class='login-right p-r'>
            <div class='login-ipt-box'>
                <input  class='login-ipt input-name' type="text" v-model='username' name='username' placeholder="请输入账号">
                <input  class='login-ipt input-pass' type="password" v-model='passwd' name='passwd' placeholder="请输入密码">
                <span class='icon-user'></span>
                <span class='icon-passwd'></span>
                <div class='remenber-pswd-box'>
                    <input type="checkbox" name="remember_passwd" value="1">
                    <span>记住密码</span>
                </div>
                <button class='login-btn' type='button'>确认登陆</button>
            </div>

        </div>
    </div>
</div>
</body>
<script type="text/javascript">


    $(document).on('input propertychange',function(){
        var name = $('.input-name').val();
        var pass = $('.input-pass').val();
        var member = $('[name=remember_passwd]').is(":checked") ? 1 : 0;
        if(name.length > 0 && pass.length > 5){
            $('.login-btn').addClass('on');
        }else {
            $('.login-btn').removeClass('on');
        }
    });


    $(document).on('click','.login-btn.on',function(){
        var name = $('.input-name').val();
        var pass = $('.input-pass').val();
        var member = $('[name=remember_passwd]').is(":checked") ? 1 : 0;

        $.ajax({
            url: '/login/check',
            type: 'post',
            data: {user_name:name, password:pass, member:member, _token:"{{ csrf_token() }}"},
            dataType: "json",
            success: function(re){
                if(re.code == 1){
                    layer.msg('登陆成功',{time:2000},function(){
                        window.location.href = '/worker/info';
                    });

                }else{
                    layer.msg(re.errMsg);
                }
            }
        })
    })
</script>
</html>